package com.shop2cn.iapi.agentproducts.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.activitymgt.parameter.AddactivityBean;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.SelectionActivityProductsBean;
import com.shop2cn.iapi.agentproducts.service.SelectionActivityProductsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.AgentProductCallServiceV2;
/**
*选货中心活动详情Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SelectionActivityProducts{
	private static SelectionActivityProductsBean selectionactivityproductsBean;
	private static SelectionActivityProductsCall selectionactivityproductsCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("选货中心活动详情Test");
	}

	@Before
	public void caseUp() {
		selectionactivityproductsBean=new SelectionActivityProductsBean();
		selectionactivityproductsCall=new SelectionActivityProductsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(selectionactivityproductsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SelectionActivityProducts_001() {
		Logger.start(true,"查询活动详情");
		try {
			int rootUserId = 501428441;
			int agentUserId = 501428443;
			
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					"", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			//创建限时抢活动
			AddactivityBean initProductaddactivity = AgentProductCallServiceV2.initAgenttActivity(rootUserId, productId,1,30);
			Integer activityId = AgentProductCallServiceV2.agentProductaddactivity(initProductaddactivity);
			Thread.sleep(3000);
			selectionactivityproductsBean.setUserId(agentUserId);
			selectionactivityproductsBean.setActivityId(activityId);
			selectionactivityproductsCall.setData(selectionactivityproductsBean);
			selectionactivityproductsCall.callService();			
			Logger.verifyEquals("200", selectionactivityproductsCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}